//
//  HWGiftBagCenterzhongxingViewController.m
//  HWanGame
//
//  Created by 陈道斌 on 2020/11/24.
//  Copyright © 2020 Chendaobin. All rights reserved.
//

#import "HWGiftBagCenterzhongxingViewController.h"
#import "HWOrdinaryGiftBagViewController.h"
#import "HWVipliBaoViewController.h"
#import "HWsousujiemiankongzhiqiViewController.h"


@interface HWGiftBagCenterzhongxingViewController ()<UITextFieldDelegate>
@property(strong,nonatomic) UIView *sousuview;
@property(strong,nonatomic) UIView *putonglibaoView;
@property(strong,nonatomic) UILabel *putonglabel;
@property(strong,nonatomic) UILabel *VipLabel;
@property(strong,nonatomic) HWOrdinaryGiftBagViewController *putonggiftbagView;
@property(strong,nonatomic) HWVipliBaoViewController *viplibaoViewController;





@end

@implementation HWGiftBagCenterzhongxingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self setupUI];
    
    // yhkjgame   yfcta
    
    
    [self addkongzhiqiView];
    
    
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
}



// 添加控制器View
- (void)addkongzhiqiView  {
    
    self.putonggiftbagView = [[HWOrdinaryGiftBagViewController alloc]init];
    [self addChildViewController:self.putonggiftbagView];
    
    self.viplibaoViewController  = [[HWVipliBaoViewController alloc]init];
    [self addChildViewController:self.viplibaoViewController];
    
    
    
    self.putonggiftbagView.view.frame = CGRectMake(0, NavBarHeight+54+44, kScreenW, kScreenH -NavBarHeight-54-44);
    self.viplibaoViewController.view.frame = CGRectMake(0, NavBarHeight+54+44, kScreenW, kScreenH -NavBarHeight-54-44);
    
    
    
    
    
    [self.view  addSubview:self.viplibaoViewController.view];
    [self.view addSubview:self.putonggiftbagView.view];
    
    
    
    
    
    
}


// 设置UI
- (void)setupUI {
    
    self.navigationItem.title = @"礼包中心";
    self.navigationItem.title  =    [HWjianzhiduiObject keylocalization:@"礼包中心"];
    
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    
    self.sousuview   = [[UIView alloc] initWithFrame:CGRectMake(0, NavBarHeight,kScreenW, 54)];
    self.sousuview.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.sousuview ];
    
    
    UITextField *texfeild = [[UITextField alloc]initWithFrame:CGRectMake(20, 10, kScreenW-40, 34)];
    texfeild.delegate = self;
    texfeild.placeholder = @"请输入关键字搜索";
    texfeild.placeholder  =  [HWjianzhiduiObject keylocalization:@"请输入关键字搜索"];
    texfeild.font = [UIFont systemFontOfSize:14];
    texfeild.backgroundColor = RGB(244, 243, 252);
    
    
    
    // texfeild.layer.borderColor  = RGB(208, 208, 208).CGColor;
    //   texfeild.layer.borderWidth = 0.5;
    //    UIButton *button =  [UIButton buttonWithType:UIButtonTypeCustom];
    //    button.frame = CGRectMake(0, 0, 30, 30);
    //    [button setImage:[UIImage imageNamed:@"sousukuananniu_ico"] forState:UIControlStateNormal];
    //      [button setImage:[UIImage imageNamed:@"sousukuananniu_ico"] forState:UIControlStateHighlighted];
    
    UIView *sousuoView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 35, 32)];
    UIButton *button =  [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(5, 0, 30, 30);
    [button setImage:[UIImage imageNamed:@"sousukuananniu_ico"] forState:UIControlStateNormal];
    [button setImage:[UIImage imageNamed:@"sousukuananniu_ico"] forState:UIControlStateHighlighted];
    [sousuoView addSubview:button];
    
    
    
    texfeild.leftView = sousuoView;
    texfeild.leftViewMode = UITextFieldViewModeAlways;
    texfeild.layer.cornerRadius = 15;
    texfeild.layer.masksToBounds = YES;
    //  texfeild.backgroundColor = [UIColor whiteColor];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(popUpSearchView)];
    
    [texfeild addGestureRecognizer:tap];
    
    
    [self.sousuview addSubview:texfeild];
    
    
    
    self.putonglibaoView = [[UIView  alloc]initWithFrame:CGRectMake(0,  self.sousuview.bottom, kScreenW, 44)];
    self.putonglibaoView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:self.putonglibaoView];
    
    
    
    self.putonglabel   = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    
    
    
    
    
    UILabel *nameLabel1 = [[UILabel alloc]initWithFrame:CGRectMake((kScreenW/2 -100)/2, 7, 100, 30)];
    //     nameLabel.text = fanlilistArr[i];
    //  nameLabel.backgroundColor =  RGB(248, 119, 6);
    nameLabel1.backgroundColor = [UIColor clearColor];
    nameLabel1.textAlignment = NSTextAlignmentCenter;
    nameLabel1.font = [UIFont fontWithName:@"Helvetica-Bold" size:16];;
    nameLabel1.textColor = RGB(68, 68, 68);
    //     nameLabel.layer.cornerRadius = 8;
    //     nameLabel.layer.masksToBounds = YES;
    nameLabel1.text = @"普通礼包";
    
    nameLabel1.text =  [HWjianzhiduiObject keylocalization:@"普通礼包"];
    
    self.putonglabel = nameLabel1;
    nameLabel1.userInteractionEnabled = YES;
    [self.putonglibaoView   addSubview:nameLabel1];
    UITapGestureRecognizer *putongtap =  [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(putonglabelTap)];
    [self.putonglabel   addGestureRecognizer:putongtap];
    
    
    
    
    
    
    
    
    UILabel *nameLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW/2 +(kScreenW/2 -100)/2, 7, 100, 30)];
    //     nameLabel.text = fanlilistArr[i];
    //  nameLabel.backgroundColor =  RGB(248, 119, 6);
    nameLabel2.backgroundColor = [UIColor clearColor];
    nameLabel2.textAlignment = NSTextAlignmentCenter;
    nameLabel2.font = [UIFont systemFontOfSize:14];
    nameLabel2.textColor = RGB(68, 68, 68);
    //     nameLabel.layer.cornerRadius = 8;
    //     nameLabel.layer.masksToBounds = YES;
    nameLabel2.text = @"VIP专属礼包";
    
    nameLabel2.text =  [HWjianzhiduiObject keylocalization:@"VIP专属礼包"];
    self.VipLabel = nameLabel2;
    nameLabel2.userInteractionEnabled = YES;
    
    [self.putonglibaoView   addSubview:nameLabel2];
    UITapGestureRecognizer *viplabe =  [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(viplabeTap)];
    [self.VipLabel   addGestureRecognizer:viplabe];
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
    
    // [self popUpSearchView];
    
    
    return NO;
}

- (void)popUpSearchView {
    
    
    NSLog(@"搜索界面");
    
    //    HWsousujiemiankongzhiqiViewController *sousu = [[HWsousujiemiankongzhiqiViewController alloc]init];
    //    [self.navigationController pushViewController:sousu animated:YES];
    
    
    
    NSString *typeStr = @"1";
    if (self.putonggiftbagView.view.hidden == YES) {
        
        typeStr = @"1";
        
        
    } else {
        
        typeStr = @"0";
        
    }
    
    HWsousujiemiankongzhiqiViewController *modal = [[HWsousujiemiankongzhiqiViewController alloc]init];
    modal.modalPresentationStyle = UIModalPresentationOverFullScreen;
    modal.typeStr = typeStr;
    [self presentViewController:modal animated:YES completion:nil];
    
    
    
    
}

//普通礼包
- (void)putonglabelTap  {
    
    NSLog(@"普通礼包");
    self.putonggiftbagView.view.hidden = NO;
    self.viplibaoViewController.view.hidden  = YES;
    
    
    
    [self.putonglabel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:16]];
    self.VipLabel.font = [UIFont systemFontOfSize:14];
    
}





// vip 包
- (void)viplabeTap {
    
    NSLog(@" vip 包");
    
    self.putonggiftbagView.view.hidden =YES  ;
    self.viplibaoViewController.view.hidden  = NO;
    
    self.putonglabel.font = [UIFont systemFontOfSize:14];
    
    self.VipLabel.font =[UIFont fontWithName:@"Helvetica-Bold" size:16];
    
    
    // 推荐指数
    
}




@end
